﻿using System;
using System.Data.SqlClient;
using Devv.Core.UniDataTier;

namespace Yglu.BusinessLayer.Entities
{
	public class SystemConfig : BaseEntity
	{
		#region Properties

		public String CompanyName { get; set; }
		public String GeneralPhone { get; set; }
		public String GeneralEmail { get; set; }
		public String DynamicContentsPath { get; set; }
		public String DynamicContentsUrl { get; set; }
		public String CurrencySymbol { get; set; }

		#endregion

		#region Extra properties

		public String ProductIconsPath
		{
			get
			{
				return DynamicContentsPath + "ProductIcons/";
			}
		}

		public String ProductIconsUrl
		{
			get
			{
				return DynamicContentsUrl + "ProductIcons/";
			}
		}

		#endregion

		#region Constructor

		public SystemConfig()
		{
		}

		public SystemConfig(SqlDataReader reader)
		{
			Construct(reader);
		}

		#endregion

		#region Methods

		public override void Load(SqlDataReader reader)
		{
			Id = DataHandler.GetInt32(reader, "SystemConfigId");
			CompanyName = DataHandler.GetString(reader, "SystemConfigCompanyName");
			GeneralPhone = DataHandler.GetString(reader, "SystemConfigGeneralPhone");
			GeneralEmail = DataHandler.GetString(reader, "SystemConfigGeneralEmail");
			DynamicContentsPath = DataHandler.GetString(reader, "SystemConfigDynamicContentsPath");
			DynamicContentsUrl = DataHandler.GetString(reader, "SystemConfigDynamicContentsUrl");
			CurrencySymbol = DataHandler.GetString(reader, "SystemConfigCurrencySymbol");
			Active = DataHandler.GetBoolean(reader, "SystemConfigActive");
		}

		#endregion
	}
}